package com.nw.controller;

import com.nw.entity.Cargo;
import com.nw.service.CargoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("cargo")
public class CargoController {
    @Resource
    CargoService cargoService;


    @RequestMapping("queryAllCargo")
    public List<Cargo> queryAllCargo(){
        List<Cargo> cargoList = cargoService.queryAllCargo();
        return cargoList;
    }

    @RequestMapping("getGoodlistById")
    public HashMap<String, Object> queryCargoById(String cargoId){
        HashMap<String, Object> map = cargoService.queryCargoById(cargoId);
        return map;
    }

    @RequestMapping("getGoodlist")
    public HashMap<String, Object> queryCargoByCategory(String categoryName){
        HashMap<String, Object> map = cargoService.queryCargoByCategory(categoryName);
        return map;
    }

    @RequestMapping("addCargo")
    public HashMap<String, Object> addCargo(Cargo cargo){
        HashMap<String,Object> map = cargoService.addCargo(cargo);
        return map;
    }

    @RequestMapping("uploadPic")
    public HashMap<String, Object> uploadCargoPic(MultipartFile cargoPic,String cargoId){
        HashMap<String, Object> map = cargoService.uploadCargoPic(cargoPic,cargoId);
        return map;
    }

    @RequestMapping("deleteCargo")
    public HashMap<String, Object> deleteCargo(Cargo cargo){
        HashMap<String, Object> map = cargoService.deleteCargo(cargo);
        return map;
    }

    @RequestMapping("updateCargoPrice")
    public HashMap<String, Object> updateCargoPrice(Cargo cargo){
        HashMap<String, Object> map = cargoService.updateCargoPrice(cargo);
        return map;
    }
}
